package cn.ynu.cmrs.adapter;

import cn.ynu.cmrs.activity.CourseFragment;
import cn.ynu.cmrs.activity.LiveTeleFragment;
import cn.ynu.cmrs.model.College;

import com.viewpagerindicator.TitleProvider;

import android.app.Activity;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

public class AllCourseAdapter extends FragmentPagerAdapter implements
		TitleProvider {

	private College colleges;
	private Activity mAcitivity;

	public AllCourseAdapter(FragmentManager fm, College college,
			Activity mAcitivity) {
		super(fm);
		this.colleges = college;
		this.mAcitivity = mAcitivity;
	}

	@Override
	public Fragment getItem(int position) {
		if (colleges.getItems().get(position).getName().contains("直播")) {
			return LiveTeleFragment.newInstance(mAcitivity);
		} else {
			return CourseFragment.newInstance(
					colleges.getItems().get(position));
		}
	}

	@Override
	public int getCount() {
		return colleges.getItems().size();
	}

	@Override
	public String getTitle(int position) {
		// TODO Auto-generated method stub
		return colleges.getItems().get(position).getName();
	}
}